### Project 20 Use Tilt Sensor to Control LED **1.Overview** When design circuits, sometimes you will need to test whether an object is tilted left or right, so in this case you can use our tilt sensor. In this project, you will learn how to use our digital tilt sensor to control the LED. At the same time, the LED dot matrix of Micro: bit and the CoolTerm serial port monitor display the digital signal read by the vibration tilt module. **2.Components Required** - Micro:bit Main Board\*1 - Keyestudio Edge Connector IO Breakout Board for Micro:bit\*1 - USB Cable\*1 - Keyestudio Digital Tilt Sensor\*1 - Alligator Clip Wires\*6 - keyestudio micro bit honeycomb 1W LED Module\*1 **3.Component Introduction** ![](media/image-20260128142517179.png) **About Keyestudio micro bit honeycomb vibration tilt module** Keyestudio micro bit honeycomb vibration tilt module is fully compatible with micro bit control board. In the experiment, we connect it with the micro: bit by a crocodile clip. There are 6 sockets on it, 2 G, 2 V and 2 S, which are connected. Additionally, G is GND, VV is VCC, and S is the signal end of the module. Its function is to detect vibration and tilt. The SW-200D vibration switch element adopted on this module is a ball type tilt induction unidirectional trigger switch, one end of which is gold-plated(trigger end), another one is silver-plated (conductive end). When the module is in the horizontal position or inclined to the conductive end (silver-plated), the switch element is in OFF state and the signal end outputs the high level; when the module is tilted to the trigger terminal (gold-plated), the switch element is ON state, and the signal terminal outputs the low level. When the angle of the conductive end (silver-plated)is lower than 10 ° horizontally and the module is shaken by external force, so the trigger end (gold-plated) will be in a short-time ON state, which makes the module detect vibration. **4.Technical Parameters** - Working voltage: DC 3.3-5V - Working current: 60mA - Maximum power: 300mW - Working temperature: -25 ℃ \~-65 ℃ - Size: 30mm \* 27mm \* 5mm - Weight: 2.0g - Environmental attributes: ROHS **5.Connection Diagram** Attach the main board to Keyestudio Edge Connector IO Breakout Board for Micro:bit; Connect the keyestudio micro bit honeycomb viberation tilt module to the shield with 3 Alligator clip cables; Ring S to P0, V to 3V, and G to GND. Connect the keyestudio micro bit 1W LED module to the shield with 3 Alligator clip cables. Ring S to P1, V to 3V, and G to GND. Interface the micro:bit to your computer with a micro USB cable. ![](media/image-20260128142701884.png) **6.Coding** So now let's move to coding. Below are some steps to follow. Open the [https://makecode.micro:bit.org/\#editor](https://makecode.microbit.org/#editor) to write your code. Microsoft MakeCode is actually a platform that allows us to code for a micro:bit, and also provides an interactive simulator where we can debug and run our code, and will be able to see what to expect out right there on the site. Go to MakeCode and choose **My Projects** and click on **New Projects**. If you want to see the codes behind, then you can click on JavaScript and it will display JavaScript code there in IDE. ![](media/image-20260128142731569.png) **7.The following test code is for your reference** ![](media/image-20260128142757898.png) **8.Test Results** Wire according to connection diagram and upload the test code to the main board. Open CoolTerm →click Options →click SerialPort to set COM port and baud rate (set it to 115200)→click OK→click Connect. When module tilts towards trigger end(gold-plated), both the LED dot matrix of micro bit and the serial monitor display High Level(1) and the LED is on. Otherwise, when module tilts towards conductive end(silver-plated), they both show Low Level(0) and the LED turns off. The serial monitor of CoolTerm shows as below. ![](media/image-20260128142827997.png)